//
//  UserProtocalVC.m
//  FKGW
//
//  Created by song ce on 2017/4/25.
//  Copyright © 2017年 song ce. All rights reserved.
//

#import "UserProtocalVC.h"

@interface UserProtocalVC ()<UIWebViewDelegate>
{
    UIWebView *_webView;
    
}


@end

@implementation UserProtocalVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.vcName = @"疯狂购物城平台服务协议";
    self.view.backgroundColor = [UIColor whiteColor];
    //显示加载提示
   [MBProgressHUD showLoadingGif];
    [self _initWebView];
   
}


- (void)_initWebView {
    _webView = [[UIWebView alloc] initWithFrame:CGRectMake(5, kNaviBarHeight, Main_Screen_Width-10, Main_Screen_Height-kNaviBarHeight)];
    
    //设置webView适应屏幕的大小
    _webView.scalesPageToFit = YES;
    
    //设置代理
    _webView.delegate = self;
    _webView.backgroundColor = [UIColor whiteColor];
    _webView.scrollView.showsVerticalScrollIndicator = NO;
    
    [self.view addSubview:_webView];
    
    //（1）显示网络：根据网络连接
    //https://www.baidu.com  URL
    //    NSString *str = @"https://www.baidu.com";
    //    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:str]];
    //    [webView loadRequest:request];
    
    //    （2）加载html文件
    
    NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"news" ofType:@"html"];
    NSString *htmlStr = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil];
    [_webView loadHTMLString:htmlStr baseURL:nil];
    
}

#pragma mark - UIWebViewDelegate
//网络开始加载
- (void)webViewDidStartLoad:(UIWebView *)webView {
    DLog(@"网络开始加载");
    //显示加载提示
//    [MBProgressHUD showActivityMessageInWindow:@""];
}

//网络加载完成
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    DLog(@"网络加载完成");
    //隐藏加载提示
    [MBProgressHUD dismissHUD];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
